package com.oocl.processdData.util;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Scanner;

public class FileUtil {
	
	
	private OutputStream os;
	private BufferedOutputStream bos;
	
	
	public static ArrayList<String> readData(String path){
		Scanner scanner = null;
		ArrayList<String> txtDatas = new ArrayList<String>();
		if(path != null || !path.equals("")){
			try {
				scanner = new Scanner(new File(path));
				while(scanner.hasNext()){
					txtDatas.add(scanner.nextLine());
				}				
			} catch (FileNotFoundException e) {
				System.out.println("Cann't find the file: "+path);
				e.printStackTrace();
			} finally{
				scanner.close();
			}
		}
		return txtDatas;
	}
	
	public static void store(String msg) throws IOException{
		BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Mike.txt"));
		bos.write(msg.getBytes());
		bos.close();
	}
	
}
